home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
cug191
/
soundint.asz
< prev
next >
Wrap
Text File
|
1986-05-25
|
7KB
|
193 lines
;
; SOUNDINT.ASM (Aztec version) 06 Feb 86
;
; /* ------------------------------------------------------------ */
; /* This is a portion of the SOUND EFFECTS LIBRARY. */
; /* */
; /* Copyright (C) 1986 by Paul Canniff. */
; /* All rights reserved. */
; /* */
; /* This library has been placed into the public domain */
; /* by the author. Use is granted for non-commercial */
; /* pusposes, or as an IMBEDDED PORTION of a commercial */
; /* product. */
; /* */
; /* Paul Canniff */
; /* PO Box 1056 */
; /* Marlton, NJ 08053 */
; /* */
; /* CompuServe ID: 73047,3715 */
; /* */
; /* ------------------------------------------------------------ */
;
; -------------------------------------------------------------------------
; Define IBM PC ports used to control speakers
;
KBCTL EQU 61H ;Keyboard control port (controls speaker too)
SPKTMR EQU 42H ;8253 Timer address
SPKCTL EQU 43H ;8253 Timer address
;
; -------------------------------------------------------------------------
; Set up macros for segment values, etc.
;
;
codeseg segment para public 'code'
dataseg segment para public 'data'
dummy DW 0
dataseg ends
assume cs:codeseg,ds:dataseg,es:dataseg,ss:dataseg
;
;
LPROG EQU 0
;
IF LPROG
ARGS EQU 6 ;Bytes on stack before args
ELSE
ARGS EQU 4 ;Bytes on stack before args
ENDIF
;
; -------------------------------------------------------------------------
;
IF LPROG
EXTRN sound_out_:FAR
EXTRN sound_done_:FAR
ENDIF
;
CODESEG SEGMENT BYTE PUBLIC 'code'
;
IF LPROG EQ 0
EXTRN sound_out_:NEAR
EXTRN sound_done_:NEAR
ENDIF
;
PUBLIC snd_irh_
PUBLIC snd_giv_
PUBLIC snd_siv_
PUBLIC snd_brk_
;
;
;
snd_irh_ PROC FAR
STI ; Enable interrupts
PUSH DS ;\
PUSH ES ; \
PUSH SI ; \
PUSH DI ; \
PUSH BP ; Save all registers
PUSH AX ; /
PUSH BX ; /
PUSH CX ; /
PUSH DX ;/
MOV AX,SEG dummy ;\
MOV ES,AX ; Load expected segment values
MOV DS,AX ;/
CALL sound_out_ ; Call the real code
POP DX ;\
POP CX ; \
POP BX ; \
POP AX ; \
POP BP ; Restore all registers
POP DI ; /
POP SI ; /
POP ES ; /
POP DS ;/
INT 61H ; Call previous INT vector
IRET ; Return
snd_irh_ ENDP
;
;
IF LPROG
snd_giv_ PROC FAR
ELSE
snd_giv_ PROC NEAR
ENDIF
PUSH BP ;Save frame pointer
MOV BP,SP ;Make new frame pointer
PUSH ES ;Preserve ES, just in case
XOR AX,AX ;Zero ES register so it will
MOV ES,AX ; point to low memory
MOV BX,[BP+ARGS] ;Make BX into proper offset,
SHL BX,1 ; which is the vector number
SHL BX,1 ; times 4 (2 shifts)
PUSHF ;Save INT flag
CLI ;Disable interrupts
MOV DX,ES:[BX+2] ;Get the high ...
MOV AX,ES:[BX] ; ... and low words of vector
POPF ;Restore INT flag
POP ES ;Preserve ES, just in case
POP BP ;Restore caller's frame
RET
snd_giv_ ENDP
;
;
IF LPROG
snd_siv_ PROC FAR
ELSE
snd_siv_ PROC NEAR
ENDIF
PUSH BP ;Save frame pointer
MOV BP,SP ;Make new frame pointer
PUSH ES ;Preserve ES, just in case
XOR AX,AX ;Zero ES register so it will
MOV ES,AX ; point to low memory
MOV BX,[BP+ARGS] ;Make BX into proper offset,
SHL BX,1 ; which is the vector number
SHL BX,1 ; times 4 (2 shifts)
PUSHF ;Save INT flag
CLI ;Disable interrupts
MOV AX,[BP+ARGS+2] ;Get low word of vector
MOV ES:[BX],AX ; and install it.
MOV AX,[BP+ARGS+4] ;Get high word of vector
MOV ES:[BX+2],AX ; and install it.
POPF ;Restore INT flag
POP ES ;Preserve ES, just in case
POP BP ;Restore caller's frame
RET
snd_siv_ ENDP
;
;
snd_brk_ PROC FAR
STI
PUSH DS ;\
PUSH ES ; \
PUSH SI ; \
PUSH DI ; \
PUSH BP ; Save all registers
PUSH AX ; /
PUSH BX ; /
PUSH CX ; /
PUSH DX ;/
MOV AX,SEG dummy ;\
MOV ES,AX ; Load expected segment values
MOV DS,AX ;/
CALL sound_done_ ; Tidy up loose ends
CLC ; Clear Carry (see above desc.)
INT 23H ; Call the real handler
POP DX ;\
POP CX ; \
POP BX ; \
POP AX ; \
POP BP ; Restore all registers
POP DI ; /
POP SI ; /
POP ES ; /
POP DS ;/
JC abort ; Abort if handler set carry flag
;
cont: IRET ; Continue, use IRET
;
abort: POPF ; Get flags off stack
STC ; Pass "abort" message back to DOS
RET ; Long return to DOS
snd_brk_ ENDP
;
;
codeseg ends
END